import { instance } from '../request'

const request = instance

/**
 * 获取角色路由详情
 * @param roleId 角色id
 * @returns
 */
export const getRoleRoutesDetailApi = (roleId: string): PromiseRes<RouteItf[]> =>
  request.get(`/roleRoutes/roleRoutesDetail/${roleId}`)

/**
 * 为角色批量设置路由
 * @param roleId 角色id
 * @param type 类型 （refresh, add, remove）
 * @param routesIdList 权限id 列表
 * @returns
 */
export const setRoleRoutesApi = (
  roleId: string,
  type: 'refresh' | 'add' | 'remove',
  routesIdList: string[]
): PromiseRes =>
  request.post(`/roleRoutes/setRoleRoutes/${roleId}?type=${type}`, routesIdList)
